<template>
    <Layout>
        <Form ref="form1" :model="form1" :label-width="120">
            <Row class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="问题描述:">
                        <Input type="text" v-model="form1.rpoblemDesc"/>
                    </FormItem>
                </Col>
                <!--<Col span="8">
                    <FormItem label="问题状态:">
                        <Select  v-model="form1.problemState">
                            <Option value="0" >待确认</Option>
                            <Option value="1" >已确认</Option>
                        </Select>
                    </FormItem>
                </Col>-->
                <Col span="8">
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
        </Form>

        <Table ref='table' :height="tableHeight" class="table" no-data-text="没有查询到相关数据！" :loading="buttonLoading" size="small"
               highlight-row stripe border :columns="columns1" width="100%" :data="dataTable">
        </Table>

        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>

        <Modal title="问题审核查看" :transfer=false v-model="model3" class="modal-view-detail"  :width=900>
            <Form ref="viewForm" :label-width="100">
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="任务名称：" >
                            {{showdata.planTaskName}}
                        </FormItem>
                    </Col>
                    <Col span="11" >
                        <FormItem label="审计单位：">
                            {{showdata.auditedOrgName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="检查人：">
                             {{showdata.auditorName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="记录时间：" prop="auditTime">
                            {{this.formatDate(new Date(showdata.auditTime), 'yyyy-MM-dd')}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="审计标准项目：">
                            {{showdata.factorName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="审计标准内容：" >
                            {{showdata.subitemName}}
                        </FormItem>
                    </Col>
                </Row>
                 <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="扣分：" prop="auditScore">
                            {{showdata.auditScore}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="问题状态:">
                            {{showdata.problemStateName}}
                        </FormItem>
                    </Col>
                </Row>

                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23" >
                        <FormItem label="问题描述：" prop="rpoblemDesc">
                            {{showdata.rpoblemDesc}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="问题图片:">
                            <div class="demo-upload-list" v-for="item in upLoadList1" :key="item.id">
                                <img :width= "100" :height= "100" :src="item.url">
                                <!--
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>-->
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <div slot="footer">
                    <Button class='ivu-btn-save' @click="model3=false" >关闭</Button>
                    <!--<Button class='ivu-btn-cancel' @click="handleCancel" >取消</Button>-->
                </div>
            </Form>
        </Modal>
        <Modal title="审计任务选择" :transfer=false footer-hide v-model="missionSelectModal"  :width=800 >
            <missionSelect  ref="selMission" @selectMission="selectMission" >
            </missionSelect>
        </Modal>
        <Modal title="问题修改" :transfer=false v-model="model12" :width=800 >
            <Form ref="viewForm" :label-width="100">
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="任务名称：" >
                            {{form1datacopy.planTaskName}}
                        </FormItem>
                    </Col>
                    <Col span="11" >
                        <FormItem label="审计单位：">
                            {{form1datacopy.auditedOrgName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="检查人：">
                             {{form1datacopy.auditorName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="记录时间：" prop="auditTime">
                            <DatePicker type="date" format="yyyy-MM-dd"  placeholder="请选择登陆时间"
                                v-model="form1datacopy.auditTime"></DatePicker>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="审计标准项目：">
                                <Input type="text" v-model="form1datacopy.factorName"  readonly >
                                <Button slot="append" @click="openExpertSelector()" icon="ios-search"></Button>
                            </Input>
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="审计标准内容：" >
                                {{form1datacopy.subitemName}}
                        </FormItem>
                    </Col>
                </Row>
                 <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="扣分：" prop="auditScore">
                            <Input v-model="form1datacopy.auditScore" number ></Input>
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="问题状态:">
                            <Select label-in-value v-model="form1datacopy.problemState" @on-change="problemStateSelect">
                                <Option value="0" >待确认</Option>
                                <Option value="1" >已确认</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>

                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23" >
                        <FormItem label="问题描述：" prop="rpoblemDesc">
                            <Input v-model="form1datacopy.rpoblemDesc" type="textarea" :rows="3" />
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="问题图片:">
                            <div class="demo-upload-list" v-for="item in upLoadList1" :key="item.id">
                                <img :width= "100" :height= "100" :src="item.url">
                                <!--
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>-->
                            </div>
                        </FormItem>
                    </Col>
                </Row>
               <!-- <Row type="flex" justify="center" class="code-row-bg">
                    <Col span="23" >
                        <FormItem>
                            <Button class='ivu-btn-save' @click="submit('form1datacopy')" >确定</Button>
                            <Button class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
                        </FormItem>
                    </Col>
                </Row>-->
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="submit('form1datacopy')" >确定</Button>
                <Button class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
            </div>
        </Modal>
    </layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    import cascaderDom from '@/components/cascader-dom'
    import {sessionStorage} from '@/common/cacheUtils.js'
    import missionSelect from "./missionSelect.vue"
    export default {
        components: {
            cascaderDom,missionSelect
        },
        data() {
            return {
                missionId:'',
                model12: false,
                showdata: {},
                expertSelectModal: false,
                buttonLoading:false,
                fileUrl: Api.interestedPartiesUserFile,
                upLoadList1: [],
                form1datacopy:{},
                missionSelectModal:false,
                form1: {},
                dataForm: {},
                chkProblem : {},
                //分页参数
                pageSizeArray: [10, 20, 50],
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                },
                columns1: [
                    {
                        title: "序号",
                        width: 80,
                        align: "center",
                        fixed: 'left',
                        render: (h, params) => {
                            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
                        }
                    },
                    {
                        minWidth: 200,
                        title: '项目',
                        key: 'factorName',
                        align: 'center'
                    },
                    {
                        minWidth: 250,
                        title: '审计内容',
                        key: 'subitemName',
                        align: 'center'
                    },
                    {
                        minWidth: 220,
                        title: '问题描述',
                        key: 'rpoblemDesc',
                        align: 'center'
                    },
                    {
                        minWidth: 150,
                        title: '总分',
                        key: 'factorScore',
                        align: 'center'
                    },
                    {
                        minWidth: 250,
                        title: '问题图片',
                        align: 'center',
                        key: 'imgsrc',
                        render:  (h, params) => {
                            //console.log('pictureId=',params.row)
                            let ps  = params.row.pictureId.split(':')
                            
                            let hFn = []

                            ps.forEach(v=>{
                                if(v){
                                    let url = this.fileUrl + '/file/' + v
                                    hFn.push(
                                        h('img', {
                                            style: {
                                                width: "30px",
                                                margin: "3px"
                                            },
                                            attrs: {
                                                src: url
                                            }
                                        })
                                    )
                                }
                            })
                            //console.log('222',hFn)
                            return h('div', [...hFn
                                // h('img', {
                                //         style: {
                                //             width: "30px",
                                //         },
                                //         attrs: {
                                //             src: url
                                //         }
                                // }),
                                //  h('img', {
                                //         style: {
                                //             width: "30px",
                                //         },
                                //         attrs: {
                                //             src: url
                                //         }
                                // })
                            ]);
                        }
                    },
                    {
                        minWidth: 150,
                        title: '扣分',
                        key: 'auditScore',
                        align: 'center'
                    },
                    {
                        minWidth: 150,
                        title: '问题状态',
                        key: 'problemStateName',
                        align: 'center'
                    },
                    // {
                    //     minWidth: 180,
                    //     title: '问题描述',
                    //     key: 'rpoblemDesc',
                    //     align: 'center',
                    //     render: (h, params) => {
                    //         return h('div', [
                    //             h('span', (params.row.rpoblemDesc && params.row.rpoblemDesc.length) < 10 ?
                    //                 params.row.rpoblemDesc : params.row.rpoblemDesc.substr(0, 9) + '...')
                    //         ]);
                    //     }
                    // },
                    {
                        minWidth: 100,
                        title: '审计专家',
                        key: 'auditorName',
                        align: 'center'
                    },
                    {
                        minWidth: 130,
                        title: '检查日期',
                        key: 'auditTime',
                        align: 'center',
                        render:(h,params)=>{
                            return h('div',[
                                (this.formatDate(new Date(params.row.auditTime), 'yyyy-MM-dd'))
                            ]);
                        }
                    },
                ],
                ruleCustom: {
                    auditScore: {required: true, type: 'number', message: ' ', trigger: 'change'},
                    factorName: [{
                        required: true,
                        message: '  ',
                        trigger: 'change'
                    }],
                    auditorId: [
                        { required: true, message: '  ', trigger: 'blur' }
                    ],
                    rpoblemDesc: [{
                        required: true,
                        message: '  ',
                        trigger: 'change'
                    }],
                    
                },
                dataTable: [],
                model1: false,
                model11: false,
                tableHeight: '',
                model3: false,
                viewForm: {},
                setCurrentExpectUserName : {},
                setCurrentAssignUserName : {},

                uploadList : [],
                uploadImgs : [],
                visible: false,
                viewUrl : Api.downloadPTWSchemeFile,
                upUrl:Api.uploadPTWFiles,
                editable : false,
            }
        },
        mounted: function () {
            this.tableHeight = window.innerHeight - 220;
            this.query();

            //console.log('1111111111111',sessionStorage('userId').getObject('userId'))
        },
        
        methods: {
            problemStateSelect(appStatus) {
                this.form1datacopy.problemState = appStatus.value;
                this.form1datacopy.problemStateName = appStatus.label;
            },
            getActivityData(row){
                //console.log('aaa',row)
                this.form1datacopy.factorId = row.itemId
                this.form1datacopy.factorName = row.itemName
                this.form1datacopy.subitemId = row.subitemId
                this.form1datacopy.subitemName = row.subitemName
                this.expertSelectModal = false;
            },
            openExpertSelector(){
                this.expertSelectModal = true;
            },
            closeExpertSelectModal(){
                this.expertSelectModal = false;
            },
            setUserName1(data) {
                this.form1datacopy.auditorName = data;
            },
            setUserId1(data) {
                this.form1datacopy.auditorId = data[data.length - 1];
            },
            selectMission(row){
                //this.$refs.childUser.resetCurrentOrg();
                this.missionSelectModal = false
                this.form1datacopy = {
                    problemId: this.get_uuid(),
                    planTaskName: row.missionName,
                    planTaskId: row.missionId,
                    auditTime: new Date(),
                    auditedOrgName: row.auditedOrgName,
                    problemState: '0',
                    problemStateName:'待确认'
                };
                this.model11 = true;
                this.add = true;
            },
            beforeUpload(file) {
                let formData = new FormData();
                formData.append("files", file); // 文件对象
                let url = this.fileUrl + '/' + this.form1datacopy.problemId + '/files/adtProblems'
                this.$http.post(url, formData).then((res) => {
                    if (res.data.result == "success") {
                        this.$Message.info("文件上传成功")
                        this.getFiles(this.form1datacopy.problemId);
                    }
                })
                return false
            },
            getFiles(id) {
                this.upLoadList1.length = 0
                let url = this.fileUrl + '/' + id + '/files/adtProblems'
                this.$http.get(url).then((res) => {
                    if (res.data.result == "success") {
                        if(res.data.data){
                            this.upLoadList1 = res.data.data
                            this.upLoadList1 = this.upLoadList1.map(v =>{
                                    v.url = this.fileUrl + '/file/' + v.id;
                                    return v
                                })
                            }
                        console.log('aaaaaaaaaaaa',this.upLoadList1)
                    }
                })
            },
            handleRemove (file) {
                //删除操作
                let _this = this;
                let config = {
                    title: '系统提示',
                    content: '确认删除图片吗?',
                    okText: '确定',
                    cancelText: '取消',
                    onOk: function () {

                        _this.$Spin.show({
                            render: (h) => {
                                return h('div', [
                                    h('Icon', {
                                        'class': 'demo-spin-icon-load',
                                        props: {
                                            type: 'ios-loading',
                                            size: 18
                                        }
                                    }),
                                    h('div', 'Loading')
                                ])
                            }
                        });
                        _this.uploadImgs.splice(_this.uploadImgs.indexOf(file), 1);

                        _this.$http.delete(Api.downloadPTWSchemeFile  + '/' + file.id).then((res) => {
                            _this.$Message.success('删除成功');
                          /*  _this.uploadImgs = [];
                            _this.$http.get(_this.upUrl, {params: {}}).then((res) => {
                                if(res.data.data!=null){
                                    res.data.data.map((item)=>{
                                        _this.uploadImgs.push({ name : item.fileName, id : item.id , url : Api.downloadPTWSchemeFile + '/' + item.id});
                                    });
                                }
                            }).catch(e => {
                                console.log(e)
                                this.$Message.error("数据获取失败")
                            })*/

                            _this.$Spin.hide();
                        }).catch(e => {
                            _this.$Spin.hide();
                            _this.$Message.error('删除失败' + e);
                        })
                    },
                    onCancel: function () {
                    }
                }
                this.$Modal.confirm(config);
            },
            openSelect(){
                this.missionSelectModal = true
            },
            handleFormatError (file) {
                this.$Message.error('格式不正确, 请上传 jpg 或 png');
            },
            handleMaxSize (file) {
                this.$Message.error('图片不能大于1M.');
            },
            handleBeforeUpload (file) {

                if(file.size > 1024 * 1024){
                    this.$Message.error('图片不能大于1M.');
                    return false;
                }
                var index = file.name.lastIndexOf(".");
                var suffix = file.name.substr(index+1);

                if(suffix!='jpg' && suffix!='jpeg' && suffix!='png'){
                    this.$Message.error("请上传jpg,jpeg,png格式的图片");
                    return false;
                }

                const check = this.uploadImgs.length < 3;
                if (!check) {
                    this.$Message.error('最多上传3张图片');
                    return false;
                }else {
                    this.uploadImgs.push(file);
                }
                return false;
            },

            handleView (name,url) {
                this.viewUrl = url;
                this.imgName = name;
                this.visible = true;
            },

            viewPicture(row){
                //根据reportFile查询附件
                this.uploadList = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.reportFile + '/files', {params: {}}).then((res) => {
                    if(res.data.data!=null){
                        res.data.data.map((item)=>{
                            this.uploadList.push({ name : item.fileName, id : item.id , url : Api.downloadPTWSchemeFile + '/' + item.id});
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },

            viewAuditPicture(row){
                //根据reportFile查询附件
                this.uploadImgs = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.assignId + '/files', {params: {}}).then((res) => {
                    if(res.data.data!=null){
                        res.data.data.map((item)=>{
                            this.uploadImgs.push({ name : item.fileName, id : item.id , url : Api.downloadPTWSchemeFile + '/' + item.id});
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },

            handleCancel() {
                this.model1 = false;
                this.model11 = false;
                this.model12 = false;

            },

            addInfo() {
                this.dataForm = {};
                this.setCurrentExpectUserName = {};
                this.setCurrentAssignUserName = {
                    label : JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
                    value: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
                };
                setTimeout(() => {
                    this.$refs.childUser1.setCurrentUser();
                }, 300);
                this.model1 = true;
            },

            setExpectUserName(data) {
                this.dataForm.expectUserName = data;
            },
            setExpectUserId(data) {
                this.dataForm.expectUser = data[data.length - 1];
            },

            setAssignUserName(data) {
                this.dataForm.assignUserName = data;
            },
            setAssignUserId(data) {
                this.dataForm.assignUserId = data[data.length - 1];
            },

            pageChange(pageNum) {
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            pageSizeChange(pageSize) {
                this.pagedata.pageSize = pageSize;
                this.query();
            },
           
            saveData(tag) {
                this.$refs.dataForm.validate((valid) => {
                    if (valid) {
                        this.dataForm.expectDate = this.formatDate(new Date(this.dataForm.expectDate), 'yyyy-MM-dd');
                        this.dataForm.assignDate = this.formatDate(new Date(this.dataForm.assignDate), 'yyyy-MM-dd');
                        if (tag == '1') {
                            //保存
                            this.dataForm.reportStatus = '1' ;
                        }else if(tag == '2'){
                            //提交
                            this.dataForm.reportStatus = '2' ;
                        }
                        this.dataForm.problemId = this.chkProblem.problemId;
                        this.$http.post(Api.saveOrSubmitChkAssign,  this.dataForm ).then((res) => {
                            if(this.uploadImgs.length>0){
                                let formData = new FormData();
                                for(let i =0;i < this.uploadImgs.length;i ++){
                                    formData.append("files", this.uploadImgs[i]);
                                }
                                this.$http.post(Api.uploadPTWFiles + '/' + res.data.assignId + '/files/any', formData).then((res) => {
                                    if (res.data.result == "success") {
                                        this.$Message.success("保存成功");
                                        //this.uploadList.push(file);
                                        this.model1 = false;
                                        this.query();
                                    } else {
                                        this.$Message.error("附件上传失败");
                                        this.model1 = false;
                                        this.query();
                                    }
                                }).catch(e => {
                                    console.log(e);
                                    this.$Message.error("附件上传失败");
                                })
                            }else{
                                this.$Message.success("保存成功");
                                this.model1 = false;
                                this.query();
                            }
                        }).catch(e => {
                            console.log(e)
                            this.model1 = false;
                            this.query();
                            this.$Message.error("数据保存失败")
                        })
                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },
            submit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        //this.form1datacopy.planStart = this.formatDate(new Date(this.form1datacopy.planStart), 'yyyy-MM-dd');
                        //this.form1datacopy.planEnd = this.formatDate(new Date(this.form1datacopy.planEnd), 'yyyy-MM-dd');
                            
                            if(this.add){
                                let userId = sessionStorage('userId').getObject('userId').userId;
                                let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                                this.form1datacopy.createUsrId = userId;
                                this.form1datacopy.createOrgId = orgId;

                                this.$http.post(Api.createAdtProblem, this.form1datacopy).then((res) => {
                                    if (res.status === 200) {
                                        this.$Message.success('成功');
                                        this.model11 = false;
                                        this.query()

                                    }else if (res.data.status === 201) {
                                        this.$Message.error(res.data.msg);
                                        this.model11 = false;
                                    }

                                }).catch(e => {
                                    this.model11 = false;
                                    this.query();
                                    this.$Message.error("数据获取失败")
                                })
                            }else{
                                let userId = sessionStorage('userId').getObject('userId').userId;
                                let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                                this.form1datacopy.updateUserId = userId;
                                this.form1datacopy.updateOrgId = orgId;
                                this.$http.post(Api.updateAdtProblem, this.form1datacopy).then((res) => {
                                    if (res.status === 200) {
                                        this.$Message.success('成功');
                                        this.model12 = false;
                                        this.query()

                                    }else if (res.data.status === 201) {
                                        this.$Message.error(res.data.msg);
                                        this.model12 = false;
                                    }

                                }).catch(e => {
                                    this.model12 = false;
                                    this.query();
                                    this.$Message.error("数据获取失败")
                                })
                            }
                        

                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },
            query() {this.buttonLoading=true
                this.dataTable = []
                let data = {
                    currentPage: this.pagedata.currentPage,
                    size: this.pagedata.pageSize,
                }

                if(this.form1.rpoblemDesc){
                    data.rpoblemDesc=this.form1.rpoblemDesc
                }
                data.problemState='-1'
                data.planTaskId = this.missionId
                console.log('this.form1',this.form1)

                data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));

                let url = Api.queryAdtProblem;
                this.$http.get(url, {params: data}).then((res) => {
                    this.dataTable = res.data.data;
                    this.pagedata.total = res.data.totalSize;this.buttonLoading=false 
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            reset() {
                this.form1 = {};
                this.query();
            },

            deleteData(params) {
                let url = Api.deleteAdtProblem;
                this.$http.get(url,  {params: {id:params.row.problemId}}).then((res) => {
                    if (res.status === 200) {
                        this.$Message.success('成功');
                        this.query()
                    }else if (res.data.status === 201) {
                        this.$Message.error(res.data.msg);

                    }
                }).catch(e => {
                    this.$Message.error('请求失败' + e);
                })
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
            get_uuid() {
                let s = [];
                let hexDigits = "0123456789abcdef";
                for (let i = 0; i < 36; i++) {
                    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
                }
                s[14] = "4";
                s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
                s[8] = s[13] = s[18] = s[23] = "-";

                let uuid = s.join("");
                let reg = new RegExp("-", "g");
                let a = uuid.replace(reg, "");
                console.log(a);
                return a;
            },
            remove1(mainId, id) {
                let url = this.fileUrl + '/file/' + id;
                this.$http.delete(url).then((res) => {
                    this.getFiles(mainId)
                })
            },
            showData(data, flag) {
                this.getFiles(data.row.problemId)
                if (flag == 1) {
                    this.showdata = data.row;
                    this.model3 = true;
                } else {
                    this.add = false;
                    this.form1datacopy = JSON.parse(JSON.stringify(data.row));

                    this.model12 = true;
                }
            },
        },

        watch:{
            "model11":function(qw,er){
                if(qw && this.model11){
                    setTimeout(()=>{
                        this.$refs.childUser.setCurrentOrg();
                    },100)
                }else{
                    this.$refs.childUser.setCurrentUser();
                }
            },
        },
        
    }
</script>
<style lang='css' scoped>
    @import '../../../index.css';
</style>
